<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>dps.x509Helper</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">

<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="center">
    <th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
    <th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
    <th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
    <th class="navbar" align="right" width="100%">
      <table border="0" cellpadding="0" cellspacing="0">
      <tr><th class="navbar" align="center">
        <p class="nomargin">
          <a class="navbar" target="_top" href="http://code.google.com/p/dps-x509/">DPS</a>
      </p></th></tr></table>
    </th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <font size="-1"><b class="breadcrumbs">
        <a href="dps-module.html">Package&nbsp;dps</a> ::
        Module&nbsp;x509Helper
      </b></font></br>
    </td>
    <td><table cellpadding="0" cellspacing="0">
      <tr><td align="right"><font size="-2">[show&nbsp;private&nbsp;|&nbsp;<a href="../public/dps.x509Helper-module.html">hide&nbsp;private</a>]</font></td></tr>
      <tr><td align="right"><font size="-2">[<a href="frames.html"target="_top">frames</a>&nbsp;|&nbsp;<a href="dps.x509Helper-module.html" target="_top">no&nbsp;frames</a>]</font></td></tr>
    </table></td>
</tr></table>

<!-- =========== START OF MODULE DESCRIPTION =========== -->
<h2 class="module">Module dps.x509Helper</h2>


<!-- =========== START OF FUNCTION SUMMARY =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
  <th colspan="2">Function Summary</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">        byte string
</font></td>
  <td><code><span class="summary-sig"><a href="dps.x509Helper-module.html#asn1ToBytes" class="summary-sig-name"><code>asn1ToBytes</code></a>(<span class=summary-sig-arg>asn1</span>)</span></code>
<br />
convert asn1 to byte string</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">        byte string
</font></td>
  <td><code><span class="summary-sig"><a href="dps.x509Helper-module.html#base64ToBytes" class="summary-sig-name"><code>base64ToBytes</code></a>(<span class=summary-sig-arg>base64Cert</span>,
          <span class=summary-sig-arg>isSafeMode</span>)</span></code>
<br />
converts base64 to byte string.</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">        byte string
</font></td>
  <td><code><span class="summary-sig"><a href="dps.x509Helper-module.html#bytesToAsn1" class="summary-sig-name"><code>bytesToAsn1</code></a>(<span class=summary-sig-arg>bytes</span>,
          <span class=summary-sig-arg>spec</span>)</span></code>
<br />
convert byte string to asn1.</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">        string
</font></td>
  <td><code><span class="summary-sig"><a href="dps.x509Helper-module.html#bytesToBase64" class="summary-sig-name"><code>bytesToBase64</code></a>(<span class=summary-sig-arg>bytes</span>,
          <span class=summary-sig-arg>isSafeMode</span>)</span></code>
<br />
convert string byte to base64.</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">        list
</font></td>
  <td><code><span class="summary-sig"><a href="dps.x509Helper-module.html#certsToBase64" class="summary-sig-name"><code>certsToBase64</code></a>(<span class=summary-sig-arg>cert</span>)</span></code>
<br />
converts an input cert chain (may be only one) of certificates 
stripped base64.</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">        bool
</font></td>
  <td><code><span class="summary-sig"><a href="dps.x509Helper-module.html#isBase64" class="summary-sig-name"><code>isBase64</code></a>(<span class=summary-sig-arg>s</span>)</span></code>
<br />
returns true if s does not cotain any non base64 characters</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">        string
</font></td>
  <td><code><span class="summary-sig"><a href="dps.x509Helper-module.html#prettyBase64" class="summary-sig-name"><code>prettyBase64</code></a>(<span class=summary-sig-arg>base64Text</span>,
          <span class=summary-sig-arg>breakChar</span>,
          <span class=summary-sig-arg>isCsr</span>)</span></code>
<br />
format base64 with begin and end decoration</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">        string
</font></td>
  <td><code><span class="summary-sig"><a href="dps.x509Helper-module.html#prettyBase64Certificates" class="summary-sig-name"><code>prettyBase64Certificates</code></a>(<span class=summary-sig-arg>base64Certs</span>,
          <span class=summary-sig-arg>breakChar</span>)</span></code>
<br />
converts list to formatted certificate list</td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">        string
</font></td>
  <td><code><span class="summary-sig"><a href="dps.x509Helper-module.html#sanitizeStr" class="summary-sig-name"><code>sanitizeStr</code></a>(<span class=summary-sig-arg>s</span>)</span></code>
<br />
adjust string for conversion to bytes.</td></tr>
</table><br />


<!-- =========== START OF IMPORTS =========== -->
<dl>
  <dt><b>Imported modules:</b></dt>
  <dd>
    <code>pyasn1.type.base</code>,
    <code>base64</code>,
    <code>pyasn1.codec.der.decoder</code>,
    <a href="dps-module.html"><code>dps</code></a>,
    <code>pyasn1.codec.der.encoder</code>,
    <code>re</code>,
    <code>sys</code>,
    <code>keyczar.util</code>
  </dd>
</dl>


<!-- =========== START OF FUNCTION DETAILS =========== -->
<table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="details">
  <th colspan="2">Function Details</th></tr>
</table>

<a name="asn1ToBytes"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
  <h3><span class="sig"><span class="sig-name">asn1ToBytes</span>(<span class=sig-arg>asn1</span>)</span>
  </h3>
  convert asn1 to byte string
  <dl><dt></dt><dd>
    <dl><dt><b>Returns:</b></dt>
      <dd>
        byte string
      </dd>
    </dl>
    <dl><dt><b>Raises:</b></dt>
      <dd><code><b>dps.errors.DecodingError</b></code> -
        on failure
    </dl>
  </dd></dl>
</td></tr></table>

<a name="base64ToBytes"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
  <h3><span class="sig"><span class="sig-name">base64ToBytes</span>(<span class=sig-arg>base64Cert</span>,
          <span class=sig-arg>isSafeMode</span>=<span class=sig-default>False</span>)</span>
  </h3>
  converts base64 to byte string. url safe chars are decoded in safe 
  mode.
  <dl><dt></dt><dd>
    <dl><dt><b>Parameters:</b></dt>
      <dd><code><b>base64Cert</b></code> -
         input text
        <br /><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        (type=string)</i>
      <dd><code><b>isSafeMode</b></code> -
         if True convert from url safe mode otherwise perform 
        traditional base64 conversion
        <br /><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        (type=bool)</i>
      </dd>
    </dl>
    <dl><dt><b>Returns:</b></dt>
      <dd>
        byte string
      </dd>
    </dl>
    <dl><dt><b>Raises:</b></dt>
      <dd><code><b>dps.errors.DecodingError</b></code> -
        on failure
    </dl>
  </dd></dl>
</td></tr></table>

<a name="bytesToAsn1"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
  <h3><span class="sig"><span class="sig-name">bytesToAsn1</span>(<span class=sig-arg>bytes</span>,
          <span class=sig-arg>spec</span>=<span class=sig-default>None</span>)</span>
  </h3>
  convert byte string to asn1. If spec supplied decoding will contain 
  named types from the spec
  <dl><dt></dt><dd>
    <dl><dt><b>Parameters:</b></dt>
      <dd><code><b>spec</b></code>
        <br /><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        (type=dps.asn1CertificateSpecification.* or None)</i>
      </dd>
    </dl>
    <dl><dt><b>Returns:</b></dt>
      <dd>
        byte string
      </dd>
    </dl>
    <dl><dt><b>Raises:</b></dt>
      <dd><code><b>dps.errors.DecodingError</b></code> -
        on failure
    </dl>
  </dd></dl>
</td></tr></table>

<a name="bytesToBase64"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
  <h3><span class="sig"><span class="sig-name">bytesToBase64</span>(<span class=sig-arg>bytes</span>,
          <span class=sig-arg>isSafeMode</span>=<span class=sig-default>False</span>)</span>
  </h3>
  convert string byte to base64. url safe chars are used in safe 
  mode
  <dl><dt></dt><dd>
    <dl><dt><b>Parameters:</b></dt>
      <dd><code><b>bytes</b></code> -
         bytes to be converted
        <br /><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        (type=byte string)</i>
      <dd><code><b>isSafeMode</b></code> -
         if True convert to url safe mode otherwise perform traditional 
        base64 conversion
        <br /><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        (type=bool)</i>
      </dd>
    </dl>
    <dl><dt><b>Returns:</b></dt>
      <dd>
        base64 string
        <br /><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        (type=string)</i>
      </dd>
    </dl>
    <dl><dt><b>Raises:</b></dt>
      <dd><code><b>dps.errors.DecodingError</b></code> -
        on failure
    </dl>
  </dd></dl>
</td></tr></table>

<a name="certsToBase64"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
  <h3><span class="sig"><span class="sig-name">certsToBase64</span>(<span class=sig-arg>cert</span>)</span>
  </h3>
  converts an input cert chain (may be only one) of certificates 
  stripped base64. (ie. contains no header and footer)
  <dl><dt></dt><dd>
    <dl><dt><b>Parameters:</b></dt>
      <dd><code><b>cert</b></code> -
         der or base64 encoded certificate
        <br /><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        (type=string or bytes)</i>
      </dd>
    </dl>
    <dl><dt><b>Returns:</b></dt>
      <dd>
        list of base64 encoded certificates in order from top of 
        input
        <br /><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        (type=list)</i>
      </dd>
    </dl>
    <dl><dt><b>Raises:</b></dt>
      <dd><code><b>dps.errors.DecodingError</b></code> -
        if unable to perform conversion
    </dl>
  </dd></dl>
</td></tr></table>

<a name="isBase64"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
  <h3><span class="sig"><span class="sig-name">isBase64</span>(<span class=sig-arg>s</span>)</span>
  </h3>
  returns true if s does not cotain any non base64 characters
  <dl><dt></dt><dd>
    <dl><dt><b>Returns:</b></dt>
      <dd>
        bool
      </dd>
    </dl>
  </dd></dl>
</td></tr></table>

<a name="prettyBase64"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
  <h3><span class="sig"><span class="sig-name">prettyBase64</span>(<span class=sig-arg>base64Text</span>,
          <span class=sig-arg>breakChar</span>=<span class=sig-default>'\n'</span>,
          <span class=sig-arg>isCsr</span>=<span class=sig-default>False</span>)</span>
  </h3>
  format base64 with begin and end decoration
  <dl><dt></dt><dd>
    <dl><dt><b>Parameters:</b></dt>
      <dd><code><b>base64Text</b></code> -
         input text
        <br /><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        (type=string)</i>
      <dd><code><b>breakChar</b></code> -
         delimiter for string. for example, use '&lt;br/&gt;' for web 
        pages
        <br /><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        (type=string)</i>
      <dd><code><b>isCsr</b></code> -
         is true uses '-----BEGIN CERTIFICATE REQUEST-----' otherwise 
        uses '-----BEGIN CERTIFICATE-----'
        <br /><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        (type=bool)</i>
      </dd>
    </dl>
    <dl><dt><b>Returns:</b></dt>
      <dd>
        formatted text with certifcate headers and footers line breaks 
        every 64 characters
        <br /><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        (type=string)</i>
      </dd>
    </dl>
  </dd></dl>
</td></tr></table>

<a name="prettyBase64Certificates"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
  <h3><span class="sig"><span class="sig-name">prettyBase64Certificates</span>(<span class=sig-arg>base64Certs</span>,
          <span class=sig-arg>breakChar</span>=<span class=sig-default>'\n'</span>)</span>
  </h3>
  converts list to formatted certificate list
  <dl><dt></dt><dd>
    <dl><dt><b>Parameters:</b></dt>
      <dd><code><b>base64Certs</b></code> -
         input certificates
        <br /><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        (type=list)</i>
      <dd><code><b>breakChar</b></code> -
         delimiter for string. for example, use '&lt;br/&gt;' for web 
        pages
        <br /><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        (type=string)</i>
      </dd>
    </dl>
    <dl><dt><b>Returns:</b></dt>
      <dd>
        a string with line breaks at 64. takes as input multiple 
        certificates in a list. this function also wraps the base64 certs 
        in header guards. order is assumed to be correct from top 
        down.
        <br /><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        (type=string)</i>
      </dd>
    </dl>
  </dd></dl>
</td></tr></table>

<a name="sanitizeStr"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
  <h3><span class="sig"><span class="sig-name">sanitizeStr</span>(<span class=sig-arg>s</span>)</span>
  </h3>
  adjust string for conversion to bytes. it must have length % 4 = 
  0
  <dl><dt></dt><dd>
    <dl><dt><b>Parameters:</b></dt>
      <dd><code><b>s</b></code> -
         base64 input string
        <br /><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        (type=string)</i>
      </dd>
    </dl>
    <dl><dt><b>Returns:</b></dt>
      <dd>
        string padded with '=' to be of length divisible by 4
        <br /><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        (type=string)</i>
      </dd>
    </dl>
  </dd></dl>
</td></tr></table>
<br />


<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="center">
    <th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
    <th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
    <th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
    <th class="navbar" align="right" width="100%">
      <table border="0" cellpadding="0" cellspacing="0">
      <tr><th class="navbar" align="center">
        <p class="nomargin">
          <a class="navbar" target="_top" href="http://code.google.com/p/dps-x509/">DPS</a>
      </p></th></tr></table>
    </th>
  </tr>
</table>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
  <tr>
    <td align="left"><font size="-2">Generated by Epydoc 2.1 on Sun Oct 24 22:24:02 2010</font></td>
    <td align="right"><a href="http://epydoc.sourceforge.net"
                      ><font size="-2">http://epydoc.sf.net</font></a></td>
  </tr>
</table>
</body>
</html>
